var t = require;
var e = module;
var o = exports;
var n =
    (this && this.__extends) ||
    (function() {
        var t = function(e, o) {
            return (t =
                Object.setPrototypeOf ||
                ({ __proto__: [] }
                    instanceof Array &&
                    function(t, e) {
                        t.__proto__ = e;
                    }) ||
                function(t, e) {
                    for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                })(e, o);
        };
        return function(e, o) {
            function n() {
                this.constructor = e;
            }
            t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
        };
    })(),
    r =
    (this && this.__decorate) ||
    function(t, e, o, n) {
        var r,
            a = arguments.length,
            i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
        else
            for (var s = t.length - 1; s >= 0; s--)
                (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
        return a > 3 && i && Object.defineProperty(e, o, i), i;
    };
Object.defineProperty(o, "__esModule", { value: !0 });
var a = t("BootConst"),
    i = t("EventData"),
    s = t("GameData"),
    c = t("Util"),
    l = t("View"),
    u = t("WatchVideo"),
    p = t("ConfS"),
    f = t("fun"),
    d = t("Load"),
    h = t("warehouse"),
    y = require("./等级互换怪兽"),
    g = cc._decorator,
    v = g.ccclass,
    m =
    (g.property,
        (function(t) {
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                return (
                    (e.res = "等级互换"),
                    (e.左边id = new i.default(o.heroid)),
                    (e.右边id = new i.default(null)),
                    (e.列表ids = new i.default([])),
                    e
                );
            }
            var o;
            return (
                n(e, t),
                (o = e),
                (e.prototype.onEnable = function() {
                    var t = this;
                    s.default.heros.forEach(function(e) {
                            var o = p.DatasManager.HeroDatasById[e];
                            o && o.ID != t.左边id.value && t.列表ids.value.push(o.ID);
                        }),
                        this.列表ids.value.length > 0 && this.列表ids.emit();
                }),
                (e.prototype.view_content = function(t) {
                    var e = this,
                        o = t.node.children;
                    this.列表ids.value.forEach(function(n, r) {
                        var a = p.DatasManager.HeroDatasById[n],
                            i = o[r];
                        i || (((i = cc.instantiate(e.find("怪兽"))).parent = t.node), (i.active = !0));
                        var s = i.getComponent(y.default);
                        (s.onclick.clickpar = a.ID),
                        (s.sload.url.value = a.iconName),
                        (s.select.active = e.右边id.value == n);
                    });
                }),
                (e.prototype.view_左边lv = function(t) {
                    t.string = "" + f.getHeroLv(this.左边id.value);
                }),
                (e.prototype.view_右边lv = function(t) {
                    var e = p.DatasManager.HeroDatasById[this.右边id.value];
                    t.string = e ? "" + f.getHeroLv(this.右边id.value) : "0";
                }),
                (e.prototype.view_视频次数 = function(t, e) {
                    t.string = "视频次数(" + e + "/2)";
                }),
                (e.prototype.view_左边sk = function(t, e) {
                    var o = p.DatasManager.HeroDatasById[e];
                    if (o) {
                        var n = d.default.skeletonDatas[o.spinePath];
                        (t.skeletonData = n),
                        t.setAnimation(0, "Idle", !0),
                            (t.node.scale = o.ScaleHome),
                            f.showEquips(t, o);
                    }
                }),
                (e.prototype.view_右边sk = function(t, e) {
                    var o = p.DatasManager.HeroDatasById[e];
                    if (o) {
                        var n = d.default.skeletonDatas[o.spinePath];
                        (t.skeletonData = n),
                        t.setAnimation(0, "Idle", !0),
                            (t.node.scale = o.ScaleHome),
                            f.showEquips(t, o);
                    } else t.skeletonData = null;
                }),
                (e.prototype.onClick = function(t, e) {
                    var o = this;
                    switch (t) {
                        case "关闭":
                            this.hideView(), this.showView(h.default);
                            break;
                        case "等级互换":
                            if (!p.DatasManager.HeroDatasById[this.右边id.value]) return void c.toast("请选择一个怪兽");
                            u.default.show(a.dd.lvexchange, function() {
                                if (
                                    ((s.default.herolvexchangevideocount += 1), s.default.herolvexchangevideocount >= 2)
                                ) {
                                    var t = f.getHeroLv(o.左边id.value),
                                        e = f.getHeroLv(o.右边id.value);
                                    (s.default.herolvs[o.左边id.value] = e),
                                    (s.default.herolvs[o.右边id.value] = t),
                                    (s.default.herolvs = s.default.herolvs),
                                    (s.default.herolvexchangevideocount = 0);
                                }
                            });
                            break;
                        case "怪兽":
                            this.右边id.value = e;
                    }
                }),
                (e = o = r([v], e))
            );
        })(l.default));
o.default = m;